/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jsalon.cls;

import jamjun.infra.lang.JJString;
import jamjun.infra.model.SelectItemViewModel;
import jamjun.infra.model.SelectListViewModel;
import jamjun.infra.web.Json;
import jamjun.infra.web.el.SelectCaption;
import jsalon.enumtype.Gender;

/**
 *
 * @author Java
 */
public class SelectList {
    public Json GetGender(String selectedID,SelectCaption selectCaption){
        //<editor-fold desc="code">
        if (JJString.IsNullOrEmty(selectedID)) selectedID = "";
        SelectListViewModel items = new SelectListViewModel();
        if (selectCaption != selectCaption.none)
        {
            if (selectCaption == selectCaption.pleaseSelect)
            {
                SelectItemViewModel sitem1 = new SelectItemViewModel();
                sitem1.text = "please Select";
                sitem1.value = "";
                items.listItem.add(sitem1);
            }
            else
            {
                SelectItemViewModel sitem1 = new SelectItemViewModel();
                sitem1.text = "select all";
                sitem1.value = "";
                items.listItem.add(sitem1);
            }
        }
        try
        {              
            SelectItemViewModel sitem2 = new SelectItemViewModel();
            sitem2.text = Gender.man.caption();
            sitem2.value = Gender.man.toString();
            items.listItem.add(sitem2);
            SelectItemViewModel sitem3 = new SelectItemViewModel();
            sitem3.text = Gender.woman.caption();
            sitem3.value = Gender.woman.toString();
            items.listItem.add(sitem3);
            items.selected = selectedID;
            return new Json(items);
        }
        catch(Exception ex)
        {
            throw ex;
        }
        //</editor-fold>
    }
}
